<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>lesson1.11</title>
</head>
<body>
<script>
  Function.prototype.addMethod = function(name, fn){
    this.prototype[name] = fn;
    return this;
  }
  var methods = function(){};
  methods.addMethod('checkName', function () {
    // 验证姓名
    console.log('name checked');
    return this;
  }).addMethod('checkEmail', function () {
    // 验证邮箱
    console.log('email checked');
  })
    // methods.checkName() //Uncaught TypeError: methods.checkName is not a function
  var m = new methods();
  m.checkName().checkEmail();

</script>
</body>
</html>